home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / prodpack.zip / DB4PPSRC.EXE / _CATWHIC.PRG < prev    next >
Text File  |  1993-05-04  |  3KB  |  82 lines

  1. PROCEDURE _CatWhich
  2. PARAMETER pc_file, pl_result, pl_esc
  3. *---------------------------------------------------------------------
  4. * NAME
  5. *   _CatWhich - determine whether to use the assigned DBF or current view
  6. *
  7. * DESCRIPTION
  8. *   The _CatWhich procedure displays a prompt box for the user to
  9. *   select either the Current view or the DBF assigned to the object
  10. *   file.  If the user selects the Current view, the _CatWhich procedure
  11. *   will set the <pl_result> parameter to .F.  If the user selects the
  12. *   assigned catalog file, <pl_result> will be .T.
  13. *
  14. *   The prompt box will allow the user to press the first letter
  15. *   of the <pc_file> name to select it.
  16. *
  17. * SYNOPSYS
  18. *   DO _CatWhich WITH <pc_file>, <pl_result>, <pl_esc>
  19. *
  20. * PARAMETERS
  21. *   pc_file   = the file name to display for the prompt box
  22. *   pl_result = the return value, .t. to use <pc_file>,
  23. *               .f. to use Current view
  24. *   pl_esc    = if Esc pressed, return a .T., else .F.
  25. *
  26. * DEPENDENCIES
  27. *   None
  28. *---------------------------------------------------------------------
  29.  
  30.   PRIVATE lc_curkey, lc_curview, lc_pad, lc_1stkey
  31.  
  32.   pl_result = .F.
  33.   pl_esc = .F.
  34.  
  35.   lc_curview = [Current view]
  36.  
  37.   DEFINE WINDOW DBForCAT FROM 8,10 TO 16,69 DOUBLE
  38.   ACTIVATE WINDOW DBForCAT
  39.  
  40.   DEFINE MENU DBForCAT MESSAGE [Select option and press ENTER, or press ] + ;
  41.                                [first letter of desired option]
  42.     DEFINE PAD CurView OF DBForCAT PROMPT lc_curview AT 1,12
  43.     DEFINE PAD File OF DBForCAT PROMPT ( pc_file ) AT 1,35
  44.   SHOW MENU DBForCAT
  45.  
  46.   ON SELECTION PAD File OF DBForCAT DEACTIVATE MENU
  47.   ON SELECTION PAD CurView OF DBForCAT DEACTIVATE MENU
  48.  
  49.   @ 3,2 SAY [You may choose to use either the current database file]
  50.   @ 4,2 SAY [or view, or the database file or view usually]
  51.   @ 5,2 SAY [associated with the file you just selected.]
  52.  
  53.   *-- Set up ON KEY LABELs for handling the first letter selection
  54.   *-- or the menu pad.  When the user presses the first letter of the pad,
  55.   *-- issue the {Alt-<letter} to go to the pad, followed by an {Enter}
  56.   *-- to select the pad.
  57.   lc_curkey  = LEFT( lc_curview, 1 )
  58.   lc_1stkey  = LEFT( pc_file, 1 )
  59.   ON KEY LABEL &lc_1stkey KEYBOARD "{Alt-" + lc_1stkey + "}{13}"
  60.   ON KEY LABEL &lc_curkey KEYBOARD "{Alt-" + lc_curkey + "}{13}"
  61.   ACTIVATE MENU DBForCAT
  62.   ON KEY LABEL &lc_1stkey               && Clear the ON KEYs
  63.   ON KEY LABEL &lc_curkey
  64.  
  65.   IF LASTKEY() = 27                     && If the user escaped
  66.     pl_esc = .T.                        && Set escape flag to true
  67.   ELSE
  68.     lc_pad = PAD()                      && Get the pad FILE/CURVIEW
  69.  
  70.     IF lc_pad = "FILE"                  && If file pad
  71.       pl_result = .T.                   && Set the use catalog file flag
  72.     ENDIF
  73.  
  74.   ENDIF
  75.  
  76.   RELEASE MENU DBForCAT
  77.   RELEASE WINDOW DBForCAT
  78.  
  79. RETURN
  80. *-- EOP: _CatWhich WITH pc_file, pl_result
  81.  
  82.